package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/29.
 */
@HttpInlet(Conn.CART_INDEX)
public class ShopCarShowGet extends BaseAsyGet<ShopCarShowGet.ShopCarShowEntity> {

    public String uid, sid;

    public ShopCarShowGet(AsyCallBack<ShopCarShowEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected ShopCarShowEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            JSONArray array = object.optJSONArray("data");

            ShopCarShowEntity shopCarShowEntity = new ShopCarShowEntity();

            for (int i = 0; i < array.length(); i++) {

                JSONObject entityObject = array.optJSONObject(i);

                ShopCarEntity shopCarEntity = new ShopCarEntity();

                shopCarEntity.id = entityObject.optString("id");
                shopCarEntity.sid = entityObject.optString("sid");
                shopCarEntity.uid = entityObject.optString("uid");
                shopCarEntity.gid = entityObject.optString("gid");
                shopCarEntity.num = entityObject.optString("num");
                shopCarEntity.title = entityObject.optString("title");
                shopCarEntity.deprice = entityObject.optString("deprice");
                shopCarEntity.picurl = Conn.IMAGE_URL + entityObject.optString("picurl");

                shopCarShowEntity.shopCarEntityList.add(shopCarEntity);

            }

           return shopCarShowEntity;

        }


        return null;
    }

    public static class ShopCarShowEntity {

        public List<ShopCarEntity> shopCarEntityList = new ArrayList<>();
    }

    public static class ShopCarEntity {

        public String id, sid, uid,gid, num, title, deprice, picurl;

    }

}
